<?php
mysql_connect("localhost", "root", "");
mysql_select_db("ajax");
$query = mysql_query("SELECT name FROM gethint");
while ($query_row = mysql_fetch_assoc($query)) {
    $a[] = $query_row['name'];
}
$q = $_GET["q"];
if (strlen($q) > 0) {
    $hint = "";
    for ($i = 0; $i < count($a); $i++) {
        if (strtolower($q) == strtolower(substr($a[$i], 0, strlen($q)))) {
            if ($hint == "") {
                $hint = $a[$i];
            } else {
                $hint = $hint . " , " . $a[$i];
            }
        }
    }
}
if ($hint == "") {
    $response = "Bạn có thể chọn tên này!";
} else {
    $response = $hint;
}
echo $response;
?>